package kr.hkit.powerjava.chapter26;

import java.sql.Connection;
import java.util.Scanner;

import kr.hkit.powerjava.chapter26.common.ConnectionFactory;
import kr.hkit.powerjava.chapter26.common.DBUtil;
import kr.hkit.powerjava.chapter26.dto.Department;
import kr.hkit.powerjava.chapter26.service.AbsService;
import kr.hkit.powerjava.chapter26.service.DepartmentService;

public class TestMain {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Connection connection = ConnectionFactory.getConnection();
		AbsService<Department> deptSvc = new DepartmentService(sc, connection);
		deptSvc.prnMenu();
		
		//Employee 되도록 구현......
		
		DBUtil.close(connection);
		
		
/*		DepartmentDAO dao = new DepartmentDAO();*/
		/*Department d = new Department(6,"마케팅", 8);*/
		
/*		try {
			ArrayList<Department> list = dao.listItems();
			for(Department d : list){
				System.out.println(d);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		*/
/*		try{
			dao.insertItem(d);
			System.out.println("삽입 성공");
		} catch(SQLException e){
			System.err.println(e.getMessage() + " : " + e.getErrorCode());
		}
		
		
		try {
			d.setDeptName("교육");
			d.setFloor(9);
			dao.updateItembyNo(d);
			System.out.println("갱신 성공"+d);
		} catch (SQLException e) {
			System.err.println(e.getMessage() + " : " + e.getErrorCode());
		}*/
		
		
/*		try {
			dao.deleteItembyNo(new Department(6));
			System.out.println("삭제 성공");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		*/
		
		
		
/*3		Connection con = ConnectionFactory.getConnection();
		System.out.println(con);*/
		
		
/*2		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/mysql_study";
		String user = "root";
		String password = "1111";
		
		DBUtil.saveProperties("dbcon.xml", driver, url, user, password);
		*/
		
		//로드해 속성을 프린트해본다...
		
/*1		Properties prop = DBUtil.loadProperties("dbcon.xml");
		
		System.out.println(prop.getProperty("DRIVER"));
		System.out.println(prop.getProperty("URL"));
		System.out.println(prop.getProperty("USER"));
		System.out.println(prop.getProperty("PASSWORD"));*/
		
		// ----> DBproperties.java로 ......
/*		Properties prop = DBProperties.loadPropertis("dbcon.xml");
		DBProperties.prnProperties(prop);
		*/
	
	}
}
